<div class="blockcms" id="main_content">
    <div class="blocktitle">
		<h3 class="title">
                    <?php
                    
                    $allItems = $this->allItems;
                    $currentPage = $this->currentPage;

                    $item = $this->item;
                    if ($item) {
                        $itemTitle = " &raquo; " . $item['item_title'];
                    }

                    if ($currentPage) {
                        // check exists parent
                        if ($currentPage['all_parent']) {
                            $allParent = explode(',', $currentPage['all_parent']);
                            if (isset($allParent[0])) {
                                $allCategory = $this->allCategory;
                                foreach($allParent as $parentID):
                                    $parent = $allCategory[$parentID];
                                    // check to ignore root
                                    if ($parent['left'] != 1) {
                                    ?>
                                        <a href="<?php echo BASE_PATH . '/' . CURR_APP ?>?pid=<?php echo $parent['category_id']?>"><?php echo $parent['admin_title'];?></a> &raquo;
                                    <?php
                                    }
                                endforeach;
                            }
                            ?>
                            <a href="<?php echo BASE_PATH . '/' . CURR_APP ?>?pid=<?php echo $currentPage['category_id']?>"><?php echo $currentPage['admin_title'] ;?></a>
                            <?php

                            echo $itemTitle;
                        }
                    }
                    ?>
        </h3>
    </div>
        <div class="story" style="text-align:justify">
<?php


$items = $this->items;
if (count($items) > 0) {
    $count = 0;
    
    $config = Vnf::getConfigs('conf');
    $shoponline = @$config->shoponline;
    $shop_discussion = @$config->shop_discussion;
    
    foreach($items as $item):
        if ($count++ == 0) {
    ?>
        <div style="padding:10px;">
        <?php
        if ($item['item_image']) {
        $path = pathinfo($item['item_image'], PATHINFO_DIRNAME);
        $fileName = pathinfo($item['item_image'], PATHINFO_BASENAME);
        ?>
            <img src="<?=ImageUtil::getImage($path,$fileName,200,200, 100,true)?>" class="border" align="left" style="margin:5px 10px;"></img>
        <?php
        }
        ?>

            <p><?php echo $item['item_short_description'];?></p>
            <p><b>Price</b>: <?php echo $item['item_price'];?> € </p>
            <?php
            
            if ($shoponline) {
            ?>
            <div style="color:red;cursor:pointer;padding:5px 0px" onclick="javascript:addToCart(<?php echo $item['item_id'];?>)"><b>BUY NOW</b></div>
            <?php
            }
            ?>
            
            <div style="clear:both;"></div>
        </div>
        <div style="padding:5px"><?php echo $item['item_description'];?></div>
    <?php

    } // if first item
    else {
        break;
    }
    endforeach;
    $newItems = $this->newItems;
} // count  > 0
?>

            <!-- List discussion -->
            <?php
            if ($shop_discussion) {
            ?>
            <?php
            $allDiscussion = $this->discussion;
            $countThaoLuan = count($allDiscussion);
            ?>
            <?php
            if ($countThaoLuan > 0) {
            ?>
                <div class="blocktitle">
                    <h3>
                        <div style="float:left"><?=$this->translate->_('Discussion')?> (<?php echo $countThaoLuan?>)</div>
                        <div style="clear:both"></div>
                    </h3>
                </div>
            <?php
                foreach($allDiscussion as $discussion):
                ?>
                <div class="traloiitem">
                    <?php echo $discussion->description;?>
                    <div style="padding:5px 0px">
                        <div style="float:left">
                            <strong>
                            <?=$this->translate->_('Post by')?>:
                            </strong>
                            <a href="<?php echo BASE_URL?>/user/detailuser/?id=<?php echo $discussion->user_id?>"><?php echo $discussion->username?></a>
                        </div>
                        <div style="float:right">
                            <strong>
                            <?=$this->translate->_('At')?>:
                            </strong>
                            <?php echo date('d/m/Y h:i', strtotime($discussion->datecreated))?>
                        </div>
                        <div style="clear:both"></div>
                    </div>
                </div>
                <?php
                endforeach;
            }
        ?>
        <!-- end list discussion -->
        
        <!-- add discussion -->
        <div class="blocktitle">
            <h3 style="padding-top:10px">
                <div style="float:left">
                <?=$this->translate->_('Add discussion')?>
                </div>
                <div style="clear:both"></div>
            </h3>
        </div>
        
        <div style="padding:10px 0px">
            <form action="<?=BASE_URL?>/index/index/adddiscussion" method="post">
                <input type="text" id="level" name="level" /> 
                <textarea name="message" style="width:99%;height:100px"></textarea>
                <div style="padding:5px">
                    <input type="hidden" name="id" value="<?=$this->itemID?> "/>
                    <input type="submit" name="submit" value="Submit"/>
                    <input type="reset"  value="Reset"/>
                </div>
            </form>
        </div>
        <!-- end add discussion -->
        <?php
        } // shop discussion
        ?>

    </div>
    
    <?php
    $relateItems = $this->relateItems;
    if (count($relateItems) > 0) {
?>

        <div style="padding:10px 0px">
            <strong>
            <?=$this->translate->_('Relate items')?>
            </strong>
        </div>
<?php    
        foreach($relateItems as $relateItem):
        ?>
        <div style="padding:3px 0px">
        &raquo; 
        <a href="<?php echo BASE_URL?>/index/index/detail?id=<?php echo $relateItem['item_id']?>&pid=<?php echo $relateItem['category_id']?>">
            <?php echo $relateItem['item_title']?>
        </a>
        <i>
            (<?php echo date('d/m', strtotime($relateItem['datecreated']))?>)
        </i>
        </div>
        <?php
        endforeach;
    }
    
    ?>
    
</div>
